//package com.zy.oauth.shiro;
//
//import com.zy.common.utils.sign.UUID;
//import lombok.extern.slf4j.Slf4j;
//import org.apache.shiro.crypto.hash.Sha256Hash;
//import org.springframework.http.HttpStatus;
//
//import javax.servlet.http.HttpServletResponse;
//import java.io.IOException;
//import java.io.PrintWriter;
//import java.util.function.BiConsumer;
//import java.util.function.Function;
//import java.util.function.Supplier;
//
//@Slf4j
//public class Utils {
//
//    private Utils() {
//    }
//
//    /**
//     * use sha256 encrypt
//     */
//    public static Function<String, String> encryptPassword = (password) -> new Sha256Hash(password).toString();
//
//    /**
//     * get uuid
//     */
//    public static Supplier<String> uuid = () -> UUID.randomUUID().toString().replace("-", "");
//
//    /**
//     * writer message to response
//     */
//    public static BiConsumer<HttpServletResponse, String> renderString = (response, body) -> {
//        response.setStatus(HttpStatus.OK.value());
//        response.setCharacterEncoding("utf-8");
//        response.setContentType("application/json;charset=UTF-8");
//        try (PrintWriter writer = response.getWriter()) {
//            writer.print(body);
//        } catch (IOException e) {
//            log.error("response error.", e);
//        }
//    };
//
//}
